/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package View;

import Controller.*;
import Model.FournisseurDAO;
import Model.ImprimanteDAO;
import Model.MarqueDAO;
import Model.SalleDAO;
import Model.SecteurDAO;
import java.sql.Connection;
import java.sql.Date;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author Romain
 */
public class jframeImprimante extends javax.swing.JFrame {

    private Connection connect;
    private Controller.Type leType;

    public jframeImprimante(Connection connect, Controller.Type leType){
        initComponents();
        this.connect = connect;
        this.leType = leType;
        this.initCBO();
    }

    private void initCBO() {
        FournisseurDAO fournisseurDAO = new FournisseurDAO(connect);
        MarqueDAO marqueDAO = new MarqueDAO(connect);
        SalleDAO salleDAO = new SalleDAO(connect);
        SecteurDAO secteurDAO = new SecteurDAO(connect);

        Map<Integer, Fournisseur> fournisseurs = new HashMap();

        fournisseurs = fournisseurDAO.findAll();
        for (Integer mapKey : fournisseurs.keySet()) {
            // utilise ici hashMap.get(mapKey) pour accéder aux valeurs
            cboFournisseur.addItem(fournisseurs.get(mapKey));
        }

        Map<Integer, Marque> marques = new HashMap();
        marques = marqueDAO.findAll();
        for (Integer mapKey : marques.keySet()) {
            // utilise ici hashMap.get(mapKey) pour accéder aux valeurs
            cboMarque.addItem(marques.get(mapKey));
        }

        Map<Integer, Salle> salles = new HashMap();
        salles = salleDAO.findAll();
        for (Integer mapKey : salles.keySet()) {
            // utilise ici hashMap.get(mapKey) pour accéder aux valeurs
            cboSalle.addItem(salles.get(mapKey));
        }

        Map<Integer, Secteur> secteurs = new HashMap();
        secteurs = secteurDAO.findAll();
        for (Integer mapKey : secteurs.keySet()) {
            // utilise ici hashMap.get(mapKey) pour accéder aux valeurs
            cboSecteur.addItem(secteurs.get(mapKey));
        }
    }

    private Imprimante createImprimante() {
        try {
            Imprimante imp = new Imprimante();
            imp.setNumCompta(0);
            imp.setNumSerie(this.tfNumeroDeSerie.getText());
            imp.setNom(this.tfNom.getText());
            imp.setDescriptif(this.tfDescriptif.getText());
            
            Calendar gc = Calendar.getInstance();
            gc.set(Integer.valueOf(this.cboDateAchatAnnee.getSelectedItem().toString()),Integer.valueOf(this.cboDateAchatMois.getSelectedItem().toString()) - 1,Integer.valueOf(this.cboDateAchatJour.getSelectedItem().toString()));
            imp.setDateHT(gc.getTime());
            
            imp.setPrixHT(Double.valueOf(this.tfPrix.getText()));
            imp.setGarantie(Integer.valueOf(this.tfGarantie.getText()));
            imp.setNumBC(this.tfBonDeCommande.getText());
            imp.setBudget("");
            imp.setAmortissement(Integer.valueOf(this.tfAmortissement.getText()));
            imp.setType(this.leType);
            imp.setFournisseur((Fournisseur) this.cboFournisseur.getSelectedItem());
            imp.setMarque((Marque) this.cboMarque.getSelectedItem());
            imp.setSalle((Salle) this.cboSalle.getSelectedItem());
            imp.setSecteur((Secteur) this.cboSecteur.getSelectedItem());
            imp.setRefCC(this.tfRefCartoucheCyan.getText());
            imp.setRefCN(this.tfRefCartoucheNoir.getText());
            if (this.cbPortUsb.isSelected()) {
                imp.setpUSB("1");
            } else {
                imp.setpUSB("0");
            }
            if (this.cbPortParallele.isSelected()) {
                imp.setpParall("1");
            } else {
                imp.setpParall("0");
            }
            if (this.cbPortReseau.isSelected()) {
                imp.setpRes("1");
            } else {
                imp.setpRes("0");
            }
            imp.setTYPEI(this.tfTypeImprimante.getSelectedItem().toString());
            if (this.cbA3.isSelected()) {
                imp.setA3("1");
            } else {
                imp.setA3("0");
            }
            if (this.cbA4.isSelected()) {
                imp.setA4("1");
            } else {
                imp.setA4("0");
            }
            
            CodeBarre cb = new CodeBarre(imp, connect);
            imp.setNumCB(cb.creerCodeBarre());
            
            System.out.println();

            return imp;
        } catch (Exception e) {
            return null;
        }
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTextField1 = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        tfNumeroDeSerie = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        tfNom = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        tfDescriptif = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        tfPrix = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        tfGarantie = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        tfBonDeCommande = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        tfAmortissement = new javax.swing.JTextField();
        cboFournisseur = new javax.swing.JComboBox();
        cboMarque = new javax.swing.JComboBox();
        cboSalle = new javax.swing.JComboBox();
        cboSecteur = new javax.swing.JComboBox();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        tfRefCartoucheNoir = new javax.swing.JTextField();
        tfRefCartoucheCouleur = new javax.swing.JTextField();
        tfRefCartoucheCyan = new javax.swing.JTextField();
        tfRefCartoucheMagenta = new javax.swing.JTextField();
        tfRefCartoucheJaune = new javax.swing.JTextField();
        cbPortUsb = new javax.swing.JCheckBox();
        cbPortParallele = new javax.swing.JCheckBox();
        cbPortReseau = new javax.swing.JCheckBox();
        cbA3 = new javax.swing.JCheckBox();
        cbA4 = new javax.swing.JCheckBox();
        jLabel25 = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        jLabel27 = new javax.swing.JLabel();
        jLabel28 = new javax.swing.JLabel();
        bEnregistrer = new javax.swing.JButton();
        bAnnuler = new javax.swing.JButton();
        tfTypeImprimante = new javax.swing.JComboBox();
        cboDateAchatJour = new javax.swing.JComboBox();
        cboDateAchatMois = new javax.swing.JComboBox();
        cboDateAchatAnnee = new javax.swing.JComboBox();

        jTextField1.setText("jTextField1");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setFont(new java.awt.Font("Arial Black", 0, 14)); // NOI18N
        jLabel1.setText("Imprimante");

        jLabel2.setText("Numero de Serie :");

        jLabel3.setText("Nom :");

        jLabel4.setText("Descriptif :");

        jLabel5.setText("Date d'achat :");

        jLabel6.setText("Prix ( HT ) :");

        jLabel7.setText("Duree Garantie ( M ) : ");

        jLabel8.setText("Bon de commande : ");

        tfBonDeCommande.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfBonDeCommandeActionPerformed(evt);
            }
        });

        jLabel9.setText("Amorti le :");

        tfAmortissement.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfAmortissementActionPerformed(evt);
            }
        });

        jLabel10.setText("Type d'imprimante :");

        jLabel11.setText("Port USB");

        jLabel12.setText("Port parallele");

        jLabel13.setText("Port reseau");

        jLabel14.setText("A3");

        jLabel15.setText("A4");

        jLabel18.setText("References cartouches :");

        jLabel19.setText("- Noir");

        jLabel20.setText("- Couleur");

        jLabel21.setText("- Couleur Cyan");

        jLabel22.setText("- Couleur Magenta");

        jLabel23.setText("- Couleur Jaune");

        tfRefCartoucheCyan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfRefCartoucheCyanActionPerformed(evt);
            }
        });

        tfRefCartoucheMagenta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfRefCartoucheMagentaActionPerformed(evt);
            }
        });

        jLabel25.setText("Marque");

        jLabel26.setText("Fournisseur");

        jLabel27.setText("Salle");

        jLabel28.setText("Secteur");

        bEnregistrer.setText("Enregistrer");
        bEnregistrer.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bEnregistrerActionPerformed(evt);
            }
        });

        bAnnuler.setText("Annuler");
        bAnnuler.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bAnnulerActionPerformed(evt);
            }
        });

        tfTypeImprimante.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "laser", "jet d'encre" }));

        cboDateAchatJour.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));

        cboDateAchatMois.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" }));

        cboDateAchatAnnee.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1990", "1991", "1992", "1993", "1994", "1995", "1996", "1997", "1998", "1999", "2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009", "2010", "2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020" }));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jLabel1)
                        .addGap(176, 176, 176))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel11)
                            .addComponent(jLabel12))
                        .addGap(11, 11, 11)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(cbPortReseau)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(35, 35, 35)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel25)
                                            .addComponent(cboMarque, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE))))
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(33, 33, 33)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel20)
                                            .addComponent(jLabel19)
                                            .addComponent(jLabel21)
                                            .addComponent(jLabel22)
                                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                                .addComponent(jLabel23)
                                                .addComponent(bAnnuler)))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(tfRefCartoucheCouleur, javax.swing.GroupLayout.DEFAULT_SIZE, 50, Short.MAX_VALUE)
                                            .addComponent(tfRefCartoucheNoir)
                                            .addComponent(tfRefCartoucheCyan)
                                            .addComponent(tfRefCartoucheMagenta)
                                            .addComponent(tfRefCartoucheJaune)))
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(34, 34, 34)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel27)
                                            .addComponent(cboSalle, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                            .addComponent(cbPortParallele)
                            .addComponent(cbPortUsb)
                            .addComponent(bEnregistrer)))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel8)
                            .addComponent(jLabel10)
                            .addComponent(jLabel13))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(tfBonDeCommande, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(tfTypeImprimante, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabel18))))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                        .addComponent(jLabel3)
                                        .addGap(72, 72, 72))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel4)
                                        .addGap(48, 48, 48)))
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(jLabel5)
                                    .addGap(32, 32, 32)))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel6)
                                    .addComponent(jLabel2))
                                .addGap(5, 5, 5)))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(tfDescriptif, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(layout.createSequentialGroup()
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(tfNom, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 197, Short.MAX_VALUE)
                                        .addComponent(tfPrix)
                                        .addComponent(tfNumeroDeSerie, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGroup(layout.createSequentialGroup()
                                            .addComponent(cboDateAchatJour, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(cboDateAchatMois, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(cboDateAchatAnnee, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(layout.createSequentialGroup()
                                            .addComponent(jLabel7)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(tfGarantie, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGroup(layout.createSequentialGroup()
                                            .addComponent(jLabel9)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(tfAmortissement, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))))
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel28)
                                    .addComponent(cboSecteur, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel14)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cbA3)
                        .addGap(26, 26, 26)
                        .addComponent(jLabel15)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cbA4))
                    .addComponent(jLabel26)
                    .addComponent(cboFournisseur, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(tfNumeroDeSerie, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(tfNom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(tfDescriptif, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jLabel7)
                    .addComponent(tfGarantie, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cboDateAchatJour, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cboDateAchatMois, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cboDateAchatAnnee, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(tfPrix, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9)
                    .addComponent(tfAmortissement, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel8)
                            .addComponent(tfBonDeCommande, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel10)
                            .addComponent(jLabel18)
                            .addComponent(tfTypeImprimante, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel11)
                            .addComponent(jLabel19)
                            .addComponent(tfRefCartoucheNoir, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cbPortUsb))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel12)
                            .addComponent(jLabel20)
                            .addComponent(tfRefCartoucheCouleur, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cbPortParallele))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel13)
                            .addComponent(jLabel21)
                            .addComponent(tfRefCartoucheCyan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(cbPortReseau))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel14)
                        .addComponent(jLabel22)
                        .addComponent(tfRefCartoucheMagenta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(cbA3))
                    .addComponent(cbA4)
                    .addComponent(jLabel15))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel23)
                    .addComponent(tfRefCartoucheJaune, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 12, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel26)
                    .addComponent(jLabel25)
                    .addComponent(jLabel27)
                    .addComponent(jLabel28))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cboFournisseur, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cboSalle, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cboSecteur, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cboMarque, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(bEnregistrer)
                    .addComponent(bAnnuler))
                .addGap(6, 6, 6))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void tfAmortissementActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfAmortissementActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tfAmortissementActionPerformed

    private void tfRefCartoucheMagentaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfRefCartoucheMagentaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tfRefCartoucheMagentaActionPerformed

  private void bAnnulerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bAnnulerActionPerformed
      // TODO add your handling code here:
      this.setVisible(false);
  }//GEN-LAST:event_bAnnulerActionPerformed

    private void bEnregistrerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bEnregistrerActionPerformed
        new ImprimanteDAO(connect).insert(this.createImprimante());
    }//GEN-LAST:event_bEnregistrerActionPerformed

    private void tfBonDeCommandeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfBonDeCommandeActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tfBonDeCommandeActionPerformed

    private void tfRefCartoucheCyanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfRefCartoucheCyanActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tfRefCartoucheCyanActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton bAnnuler;
    private javax.swing.JButton bEnregistrer;
    private javax.swing.JCheckBox cbA3;
    private javax.swing.JCheckBox cbA4;
    private javax.swing.JCheckBox cbPortParallele;
    private javax.swing.JCheckBox cbPortReseau;
    private javax.swing.JCheckBox cbPortUsb;
    private javax.swing.JComboBox cboDateAchatAnnee;
    private javax.swing.JComboBox cboDateAchatJour;
    private javax.swing.JComboBox cboDateAchatMois;
    private javax.swing.JComboBox cboFournisseur;
    private javax.swing.JComboBox cboMarque;
    private javax.swing.JComboBox cboSalle;
    private javax.swing.JComboBox cboSecteur;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField tfAmortissement;
    private javax.swing.JTextField tfBonDeCommande;
    private javax.swing.JTextField tfDescriptif;
    private javax.swing.JTextField tfGarantie;
    private javax.swing.JTextField tfNom;
    private javax.swing.JTextField tfNumeroDeSerie;
    private javax.swing.JTextField tfPrix;
    private javax.swing.JTextField tfRefCartoucheCouleur;
    private javax.swing.JTextField tfRefCartoucheCyan;
    private javax.swing.JTextField tfRefCartoucheJaune;
    private javax.swing.JTextField tfRefCartoucheMagenta;
    private javax.swing.JTextField tfRefCartoucheNoir;
    private javax.swing.JComboBox tfTypeImprimante;
    // End of variables declaration//GEN-END:variables
}
